import http from '@/utils/axios'

/**
 * 获取应用列表
 * @returns { ResponsePromise } Axios Response
 */
export const getAppList = (query) => {
  return http({
    url: '/management-application/app/list',
    method: 'GET',
    params: query,
  })
}

/**
 * 获取客户端生命周期类型枚举
 * @returns { ResponsePromise } Axios Response
 */
export const getAppLifeCycleType = () => {
  return http({
    url: '/management-application/app/getLifeCycleList',
    method: 'GET',
  })
}

/**
 * 获取客户端领域列表
 * @returns { ResponsePromise } Axios Response
 */
export const getAppDomainList = () => {
  return http({
    url: '/management-application/field/getAllList',
    method: 'POST',
  })
}

/**
 * 获取应用详情
 * @param { string } appKey
 * @returns { ResponsePromise } Axios Response
 */
export const getAppDetail = (appKey) => {
  return http({
    url: '/management-application/app/detail',
    method: 'GET',
    params: { appKey },
  })
}

/**
 * 新增应用
 * @param { Object } data
 * @returns { ResponsePromise } Axios Response
 */
export const createApp = (data) => {
  return http({
    url: '/management-application/app/create',
    method: 'POST',
    data,
  })
}

/**
 * 更新应用
 * @param { Object } data
 * @returns { ResponsePromise } Axios Response
 */
export const updateApp = (data) => {
  return http({
    url: '/management-application/app/update',
    method: 'POST',
    data,
  })
}

/**
 * 更新应用启用、禁用状态
 * @param { Object } appId
 * @returns { ResponsePromise } Axios Response
 */
export const switchApp = (appId, enable) => {
  return http({
    url: '/management-application/app/enable',
    method: 'POST',
    params: { id: appId, enable },
  })
}

/**
 * 删除应用
 * @param { Object } appId
 * @returns { ResponsePromise } Axios Response
 */
export const deleteApp = (appId) => {
  return http({
    url: '/management-application/app/delete',
    method: 'POST',
    params: { id: appId },
  })
}

/**
 * 获取客户端列表
 * @param { Object } query
 * @returns { ResponsePromise } Axios Response
 */
export const getClientList = (query) => {
  return http({
    url: '/management-application/client/page',
    method: 'GET',
    params: query,
  })
}

/**
 * 获取客户端详情
 * @param { string } clientKey
 * @returns { ResponsePromise } Axios Response
 */
export const getClientDetail = (clientKey) => {
  return http({
    url: '/management-application/client/detail',
    method: 'GET',
    params: { clientKey },
  })
}

/**
 * 新增客户端
 * @param { Object } data
 * @returns { ResponsePromise } Axios Response
 */
export const createClient = (data) => {
  return http({
    url: '/management-application/client/create',
    method: 'POST',
    data,
  })
}

/**
 * 更新客户端
 * @param { Object } data
 * @returns { ResponsePromise } Axios Response
 */
export const updateClient = (data) => {
  return http({
    url: '/management-application/client/update',
    method: 'POST',
    data,
  })
}

/**
 * 更新客户端启用、禁用状态
 * @param { Object } clientId
 * @returns { ResponsePromise } Axios Response
 */
export const switchClient = (clientId, enable) => {
  return http({
    url: '/management-application/client/enable',
    method: 'POST',
    params: { id: clientId, enable },
  })
}

/**
 * 删除客户端
 * @param { Object } clientId
 * @returns { ResponsePromise } Axios Response
 */
export const deleteClient = (clientId) => {
  return http({
    url: '/management-application/client/delete',
    method: 'POST',
    params: { id: clientId },
  })
}
